const express = require('express')
const path = require('path')
const cs = require('cookie-session')
const app = express()
app.listen(3000)

// 静态资源
app.use(express.static('public'))

// post接受
app.use(express.urlencoded({ extended: false }))
app.use(express.json())

// session
app.use(cs({
  name: 'sessid',
  secret: 'rn,ffewkjfhhwejkfewkfweflewfjlkewjflkewfjkwfj'
}))

// 模板引擎
app.engine('html', require('express-art-template'))
app.set('views', path.join(__dirname, 'views'))

// 路由
app.use(require('./router'))


// 404页面处理
app.use((req, res) => {
  res.status(404).render('404.html')
})




